/**
 * @(#)AdController.java 2017年4月10日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;

import org.jsbd.boss.common.ResponseUtils;
import org.jsbd.boss.dao.ISysverFilterDao;
import org.jsbd.boss.domian.channel.SysverFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * 任务版本控制
 *
 * @author <a href="mailto:xupengcheng@zhexinit.com" >徐鹏程</a>
 * @version 1.0.0
 */
@RequestMapping("/taskver")
@Controller
public class TaskVerController {
    public static final Logger LOGGER = LoggerFactory.getLogger(TaskVerController.class);

    @Resource
    private ISysverFilterDao sysverFilterDao;

    @RequestMapping(value = "list", method = RequestMethod.GET)
    public String list() {
        return "/taskver/list";
    }

    @RequestMapping(value = "listdata")
    @ResponseBody
    public Map<String, Object> listdata(SysverFilter config) {
        try {
            Map<String, Object> map = new HashMap<String, Object>();
            Integer isUseful = config.getIsUseful();
            if (isUseful != null && isUseful == -1) {
                config.setIsUseful(null);
            }
            map.put("total", sysverFilterDao.selectCount(config));
            map.put("rows", sysverFilterDao.selectPageAdList(config));
            return map;
        } catch (Exception e) {
            LOGGER.error("查询出错", e);
        }
        return null;
    }


    @RequestMapping(value = "changeStatus")
    public void abandon(SysverFilter config, HttpServletResponse response) {
        try {
            sysverFilterDao.updateConfig(config);
            ResponseUtils.responseSuccess(response);
        } catch (Exception e) {
            LOGGER.error("出错", e);
            ResponseUtils.responseFailure(response);
        }
    }


}
